home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cocktail
/
front.lha
/
front
/
src
/
Listing.mi
< prev
next >
Wrap
Text File
|
1992-08-18
|
4KB
|
185 lines
(* error listing *)
(* $Id: Listing.mi,v 1.3 1991/11/21 14:47:50 grosch rel $ *)
(* $Log: Listing.mi,v $
* Revision 1.3 1991/11/21 14:47:50 grosch
* new version of RCS on SPARC
*
* Revision 1.2 90/06/11 18:45:03 grosch
* layout improvements
*
* Revision 1.1 89/01/23 15:46:50 vielsack
* fixed bug in handling no position
*
* Revision 1.0 88/10/04 14:26:50 vielsack
* Initial revision
*
*)
IMPLEMENTATION MODULE Listing;
FROM IO IMPORT StdInput, StdError, tFile,
EndOfFile, WriteNl, WriteC;
FROM Memory IMPORT Alloc, Free;
FROM Strings IMPORT tString, ReadL, WriteL;
FROM SYSTEM IMPORT ADDRESS, TSIZE;
CONST
ColFlag = '^';
LineFlag = '@';
TYPE
tErrPtr = POINTER TO tErrElmt;
tErrElmt = RECORD
code, class, line, column, infcl : SHORTCARD;
info : ADDRESS;
next : tErrPtr;
END;
VAR
start, stop, last, read: tErrPtr;
SourceLine : SHORTCARD;
PROCEDURE PutError (Code,Class,Line,Column,InfoClass: CARDINAL; Info: ADDRESS);
VAR err : tErrPtr;
BEGIN
err := Alloc (TSIZE (tErrElmt));
IF Line = 0 THEN Line := MAX (SHORTCARD) END;
WITH err^ DO
code := Code;
class := Class;
line := Line;
column := Column;
infcl := InfoClass;
info := Info;
END;
IF start = NIL THEN
(* list is emty *)
start := err;
read := err;
stop := err;
err^.next := NIL;
last := err;
ELSIF (Line < start^.line) OR
( (Line = start^.line) & (Column < start^.column) ) THEN
(* insert before start *)
err^.next := start;
start := err;
read := err;
ELSE
IF (Line > stop^.line) OR
( (Line = stop^.line) & (Column >= stop^.column) ) THEN
(* insert after stop *)
last := stop;
stop := err;
ELSIF (Line > last^.line) OR
( (Line = last^.line) & (Column >= last^.column) ) THEN
(* insert after last *)
;
ELSE
(* insert after start *)
last := start;
END;
WHILE (last^.next # NIL) &
( (Line > last^.next^.line) OR
( (Line = last^.next^.line) & (Column >= last^.next^.column) ) ) DO
(* find exact position *)
last := last^.next;
END;
err^.next := last^.next;
last^.next := err;
last := err;
END;
END PutError;
PROCEDURE HasError (): BOOLEAN;
VAR Buf : tString;
BEGIN
IF start = NIL THEN
IF ListMode = Listing THEN
WHILE NOT EndOfFile (SourceFile) DO
ReadL (SourceFile, Buf);
WriteL (ListFile, Buf);
END;
WriteC (ListFile, LineFlag);
END;
END;
RETURN start # NIL;
END HasError;
PROCEDURE GetError (VAR Code,Class,Line,Column,InfoClass: CARDINAL; VAR Info: ADDRESS);
VAR
Next : tErrPtr;
col : SHORTCARD;
Buf : tString;
BEGIN
WITH start^ DO
Code := code;
Class := class;
Line := line;
Column := column;
InfoClass := infcl;
Info := info;
Next := next;
END;
Free (TSIZE (tErrElmt), start);
IF ListMode = Listing THEN
IF read = start THEN
LOOP
IF EndOfFile (SourceFile) THEN EXIT END;
IF SourceLine >= Line THEN EXIT END;
ReadL (SourceFile, Buf);
WriteL (ListFile, Buf);
INC (SourceLine);
END;
WriteC (ListFile, LineFlag);
col := 2;
WHILE (read # NIL) & (read^.line = Line) DO
WHILE (col < read^.column) DO
WriteC (ListFile, ' ');
INC (col);
END;
IF col = read^.column THEN
WriteC (ListFile, ColFlag);
INC (col);
END;
read := read^.next;
END;
WriteNl (ListFile);
END;
WriteC (ListFile, LineFlag);
END;
IF last = start THEN
last := Next;
END;
IF stop = start THEN
stop := Next;
END;
start := Next;
IF Line = MAX (SHORTCARD) THEN Line := 0; END;
END GetError;
BEGIN
start := NIL;
read := NIL;
stop := NIL;
last := NIL;
SourceFile := StdInput;
ListFile := StdError;
ListMode := NoListing;
SourceLine := 0;
END Listing.